home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / include / tchar.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-24  |  21.4 KB  |  743 lines

  1. /*
  2.  * Copyright (C) 1986-2001 by Digital Mars
  3.  * tchar.h.  Controls mapping of string routines to either
  4.  * unicode or MBCS or sbcs variants.
  5.  * $Revision: 1.2 $
  6.  */
  7. #if __DMC__ || __RCC__
  8. #pragma once
  9. #endif
  10.  
  11. #ifndef __TCHAR_H
  12. #define __TCHAR_H 1
  13.  
  14.  
  15. # if __cplusplus
  16. extern "C" {
  17. # endif
  18.  
  19. /* Far Functions */
  20. # if __INTSIZE == 2
  21. #define _ftcscat    _fstrcat
  22. #define _ftcschr    _fstrchr
  23. #define _ftcscmp    _fstrcmp
  24. #define _ftcscpy    _fstrcpy
  25. #define _ftcscspn   _fstrcspn
  26. #define _ftcslen    _fstrlen
  27. #define _ftcsncat   _fstrncat
  28. #define _ftcsncmp   _fstrncmp
  29. #define _ftcsncpy   _fstrncpy
  30. #define _ftcspbrk   _fstrpbrk
  31. #define _ftcsrchr   _fstrrchr
  32. #define _ftcsspn    _fstrspn
  33. #define _ftcsstr    _fstrstr
  34. #define _ftcstok    _fstrtok
  35. #define _ftcsdup    _fstrdup
  36. #define _ftcsicmp   _fstricmp
  37. #define _ftcsnicmp  _fstrnicmp
  38. #define _ftcsnset   _fstrnset
  39. #define _ftcsrev    _fstrrev
  40. #define _ftcsset    _fstrset
  41. #define _ftcslwr    _fstrlwr
  42. #define _ftcsupr    _fstrupr
  43. # else
  44. /* For 32-bit models, no far functions */
  45. #define _ftcscat    _tcscat
  46. #define _ftcschr    _tcschr
  47. #define _ftcscmp    _tcscmp
  48. #define _ftcscpy    _tcscpy
  49. #define _ftcscspn    _tcscspn
  50. #define _ftcsncat    _tcsncat
  51. #define _ftcsncmp    _tcsncmp
  52. #define _ftcsncpy    _tcsncpy
  53. #define _ftcspbrk    _tcspbrk
  54. #define _ftcsrchr    _tcsrchr
  55. #define _ftcsspn    _tcsspn
  56. #define _ftcsstr    _tcsstr
  57. #define _ftcstok    _tcstok
  58. #define _ftcsdup    _tcsdup
  59. #define _ftcsicmp    _tcsicmp
  60. #define _ftcsnicmp    _tcsnicmp
  61. #define _ftcsnset    _tcsnset
  62. #define _ftcsrev    _tcsrev
  63. #define _ftcsset    _tcsset
  64. #define _ftcsclen    _tcsclen
  65. #define _ftcsnccat    _tcsnccat
  66. #define _ftcsnccpy    _tcsnccpy
  67. #define _ftcsnccmp    _tcsnccmp
  68. #define _ftcsncicmp    _tcsncicmp
  69. #define _ftcsncset    _tcsncset
  70. #define    _ftcsdec    _tcsdec
  71. #define    _ftcsinc    _tcsinc
  72. #define    _ftcsnbcnt    _tcsnccnt
  73. #define    _ftcsnccnt    _tcsnccnt
  74. #define    _ftcsnextc    _tcsnextc
  75. #define    _ftcsninc    _tcsninc
  76. #define    _ftcsspnp    _tcsspnp
  77. #define _ftcslwr    _tcslwr
  78. #define _ftcsupr    _tcsupr
  79. #define _ftcslen    _tcslen
  80. #define _ftclen        _tclen
  81. #define    _ftccpy        _tccpy
  82. #define _ftccmp        _tccmp
  83. # endif /* __INTSIZE == 2 */
  84.  
  85. # ifdef    _UNICODE
  86. /* Current UNICODE Support */
  87.  
  88. #  ifndef UNICODE
  89. #define UNICODE
  90. #  endif
  91.  
  92. #include <wchar.h>
  93.  
  94. typedef wchar_t wint_t;
  95. typedef wchar_t wctype_t;
  96. typedef wchar_t _TCHAR;
  97. typedef wchar_t _TSCHAR;
  98. typedef wchar_t _TUCHAR;
  99. typedef wchar_t _TXCHAR;
  100. typedef wint_t  _TINT;
  101.  
  102. #if !defined(_TCHAR_DEFINED)
  103. #ifndef __STDC__
  104. typedef wchar_t        TCHAR;
  105. #endif
  106. #define _TCHAR_DEFINED 1
  107. #endif
  108.  
  109. #define _TEOF        WEOF
  110. #define __T(x)        L##x
  111.  
  112. /* ProgramEntry/Environment */
  113. #define _tmain        wmain
  114. #define _tWinMain    wWinMain
  115. #define __targv        __wargv
  116. #define _tenviron    _wenviron
  117. #define _tcmdln        _wcmdln
  118. #define _tpgmptr    _wpgmptr
  119. #define __tparsecmdline __wparsecmdline
  120.  
  121. /* Formatted I/O */
  122. #define _tprintf    wprintf
  123. #define _ftprintf    fwprintf
  124. #define _stprintf    swprintf
  125. #define _sntprintf    _snwprintf
  126. #define _vtprintf    vwprintf
  127. #define _vftprintf    vfwprintf
  128. #define _vstprintf    vswprintf
  129. #define _vsntprintf    _vsnwprintf
  130. #define _tscanf        wscanf
  131. #define _ftscanf    fwscanf
  132. #define _stscanf    swscanf
  133.  
  134. /* Unformatted I/O */
  135. #define _fgettc        fgetwc
  136. #define _fgettchar    _fgetwchar
  137. #define _fgetts        fgetws
  138. #define _fputtc        fputwc
  139. #define _fputtchar    _fputwchar
  140. #define _fputts        fputws
  141. #define _gettc        getwc
  142. #define _gettchar    getwchar
  143. #define _getts        _getws
  144. #define _puttc        putwc
  145. #define _puttchar    putwchar
  146. #define _putts        _putws
  147. #define _ungettc    ungetwc
  148.  
  149. /* String conversion functions */
  150. #define _tcstold    wcstold
  151. #define _tcstod        wcstod
  152. #define _tcstol        wcstol
  153. #define _tcstoul    wcstoul
  154. #define _itot        _itow
  155. #define _ltot        _ltow
  156. #define _ultot        _ultow
  157. #define _ttoi        _wtoi
  158. #define _ttol        _wtol
  159.  
  160. /* String functions */
  161. #define _tcscat        wcscat
  162. #define _tcschr        wcschr
  163. #define _tcscpy        wcscpy
  164. #define _tcscspn    wcscspn
  165. #define _tcslen        wcslen
  166. #define _tcsncat    wcsncat
  167. #define _tcsncpy    wcsncpy
  168. #define _tcspbrk    wcspbrk
  169. #define _tcsrchr    wcsrchr
  170. #define _tcsspn        wcsspn
  171. #define _tcsstr        wcsstr
  172. #define _tcstok        wcstok
  173. #define _tcsdup        _wcsdup
  174. #define _tcsnset    _wcsnset
  175. #define _tcsrev        _wcsrev
  176. #define _tcsset        _wcsset
  177. #define _tcscmp        wcscmp
  178. #define _tcsicmp    _wcsicmp
  179. #define _tcsnccmp    wcsncmp
  180. #define _tcsncmp    wcsncmp
  181. #define _tcsncicmp    _wcsnicmp
  182. #define _tcsnicmp    _wcsnicmp
  183. #define _tcscoll    wcscoll
  184. #define _tcsicoll    _wcsicoll
  185. #define _tcsnccoll    _wcsncoll
  186. #define _tcsncoll    _wcsncoll
  187. #define _tcsncicoll    _wcsnicoll
  188. #define _tcsnicoll    _wcsnicoll
  189.  
  190. /* Execute functions */
  191. #define _texecl        _wexecl
  192. #define _texecle    _wexecle
  193. #define _texeclp    _wexeclp
  194. #define _texeclpe    _wexeclpe
  195. #define _texecv        _wexecv
  196. #define _texecve    _wexecve
  197. #define _texecvp    _wexecvp
  198. #define _texecvpe    _wexecvpe
  199. #define _tspawnl    _wspawnl
  200. #define _tspawnle    _wspawnle
  201. #define _tspawnlp    _wspawnlp
  202. #define _tspawnlpe    _wspawnlpe
  203. #define _tspawnv    _wspawnv
  204. #define _tspawnve    _wspawnve
  205. #define _tspawnvp    _wspawnvp
  206. #define _tspawnvp    _wspawnvp
  207. #define _tspawnvpe    _wspawnvpe
  208. #define _tsystem    _wsystem
  209.  
  210. /* Time functions */
  211. #define _tasctime    _wasctime
  212. #define _tctime        _wctime
  213. #define _tstrdate    _wstrdate
  214. #define _tstrtime    _wstrtime
  215. #define _tutime        _wutime
  216. #define _tcsftime    wcsftime
  217.  
  218. /* Directory functions */
  219. #define _tchdir        _wchdir
  220. #define _tgetcwd    _wgetcwd
  221. #define _tgetdcwd    _wgetdcwd
  222. #define _tmkdir        _wmkdir
  223. #define _trmdir        _wrmdir
  224.  
  225. /* Environment/Path functions */
  226. #define _tfullpath    _wfullpath
  227. #define _tgetenv    _wgetenv
  228. #define _tmakepath    _wmakepath
  229. #define _tputenv    _wputenv
  230. #define _tsearchenv    _wsearchenv
  231. #define _tsplitpath    _wsplitpath
  232.  
  233. /* Stdio functions */
  234. #define _tfdopen    _wfdopen
  235. #define _tfsopen    _wfsopen
  236. #define _tfopen        _wfopen
  237. #define _tfreopen    _wfreopen
  238. #define _tperror    _wperror
  239. #define _tpopen        _wpopen
  240. #define _ttempnam    _wtempnam
  241. #define _ttmpnam    _wtmpnam
  242.  
  243. /* Io functions */
  244. #define _taccess    _waccess
  245. #define _tchmod        _wchmod
  246. #define _tcreat        _wcreat
  247. #define _tfindfirst    _wfindfirst
  248. #define _tfindnext    _wfindnext
  249. #define _tmktemp    _wmktemp
  250. #define _topen        _wopen
  251. #define _tremove    _wremove
  252. #define _trename    _wrename
  253. #define _tsopen        _wsopen
  254. #define _tunlink    _wunlink
  255. #define _tfinddata_t    _wfinddata_t
  256. #define _tFIND        FINDW
  257.  
  258. /* Stat functions */
  259. #define _tstat        _wstat
  260.  
  261. /* Setlocale functions */
  262. #define _tsetlocale    _wsetlocale
  263.  
  264. /* Redundant "logical-character" mappings */
  265. #define _tcsclen    wcslen
  266. #define _tcsnccat    wcsncat
  267. #define _tcsnccpy    wcsncpy
  268. #define _tcsncset    _wcsnset
  269. #define    _tcsdec        _wcsdec
  270. #define    _tcsinc        _wcsinc
  271. #define    _tcsnbcnt    _wcsncnt
  272. #define    _tcsnccnt    _wcsncnt
  273. #define    _tcsnextc    _wcsnextc
  274. #define    _tcsninc    _wcsninc
  275. #define    _tcsspnp    _wcsspnp
  276. #define _tcslwr        _wcslwr
  277. #define _tcsupr        _wcsupr
  278. #define _tcsxfrm    wcsxfrm
  279.  
  280. #   if __STDC__ || defined(_NO_INLINING)
  281. #define _tccpy(_pc1,_cpc2) (*(_pc1) = *(_cpc2))
  282. #define _tccmp(_cpc1,_cpc2) (((wchar_t)*(_cpc1))-((wchar_t)*(_cpc2)))
  283. #   else /* __STDC__ */
  284. __inline void __cdecl _tccpy(wchar_t *_pc1, const wchar_t *_cpc2) { *_pc1 = *_cpc2; }
  285. __inline int __cdecl _tccmp(const wchar_t *_cpc1, const wchar_t *_cpc2) { return (int) (((wchar_t)*_cpc1)-((wchar_t)*_cpc2)); }
  286. #   endif /* __STDC__ */
  287.  
  288. /* Ctype functions */
  289. #define _istalnum    iswalnum
  290. #define _istalpha    iswalpha
  291. #define _istascii    iswascii
  292. #define _istcntrl    iswcntrl
  293. #define _istdigit    iswdigit
  294. #define _istgraph    iswgraph
  295. #define _istlower    iswlower
  296. #define _istprint    iswprint
  297. #define _istpunct    iswpunct
  298. #define _istspace    iswspace
  299. #define _istupper    iswupper
  300. #define _istxdigit    iswxdigit
  301. #define _totupper    towupper
  302. #define _totlower    towlower
  303.  
  304. /* No Lead bytes etc. for UNICODE */
  305. #define _istlegal(_c)    (1)
  306. #define _istlead(_c)    (0)
  307. #define _istleadbyte(_c)    (0)
  308.  
  309. /* Inlined Routines: For -A, these are Macros, _NO_INLINING is for MS Compatability */
  310. #  if __STDC__ || defined(_NO_INLINING)
  311. #define _wcsdec(_ws1, _ws2) ((_ws2)-1)
  312. #define _wcsinc(_ws) ((_ws)+1)
  313. #define _wcsnextc(_cws)    ((unsigned int) *(_cws))
  314. #define _tclen(_ws)    (1)
  315. #  else
  316. __inline wchar_t * __cdecl _wcsinc(const wchar_t *_ws) { return (wchar_t *)(_ws + 1); }
  317. __inline wchar_t * __cdecl _wcsdec(const wchar_t * _ws1, const wchar_t * _ws2) { return (wchar_t *)(_ws2-1); }
  318. __inline unsigned int __cdecl _wcsnextc(const wchar_t * _cws) { return (unsigned int)*_cws; }
  319. __inline size_t __cdecl _tclen(const wchar_t *_ws) { return 1; }
  320. #  endif
  321.  
  322. # else /* ndef _UNICODE */
  323. /* Single Byte and Multi-Byte Character Support */
  324. #include <string.h>
  325.  
  326. #define _TEOF        EOF
  327. #define __T(x)        x
  328.  
  329. /* ProgramEntry/Environment */
  330. #define _tmain        main
  331. #define _tWinMain    WinMain
  332. #define __targv        __argv
  333. #define __tparsecmdline __parsecmdline
  334. #  ifdef _POSIX_
  335. #define _tenviron    environ
  336. #  else
  337. #define _tenviron    _environ
  338. #  endif
  339. #define _tcmdln        _acmdln
  340. #define _tpgmptr    _pgmptr
  341.  
  342. /* Formatted I/O */
  343. #define _tprintf    printf
  344. #define _ftprintf    fprintf
  345. #define _stprintf    sprintf
  346. #define _sntprintf    _snprintf
  347. #define _vtprintf    vprintf
  348. #define _vftprintf    vfprintf
  349. #define _vstprintf    vsprintf
  350. #define _vsntprintf    _vsnprintf
  351. #define _tscanf        scanf
  352. #define _ftscanf    fscanf
  353. #define _stscanf    sscanf
  354.  
  355. /* Unformatted I/O */
  356. #define _fgettc        fgetc
  357. #define _fgettchar    _fgetchar
  358. #define _fgetts        fgets
  359. #define _fputtc        fputc
  360. #define _fputtchar    _fputchar
  361. #define _fputts        fputs
  362. #define _gettc        getc
  363. #define _gettchar    getchar
  364. #define _getts        gets
  365. #define _puttc        putc
  366. #define _puttchar    putchar
  367. #define _putts        puts
  368. #define _ungettc    ungetc
  369.  
  370. /* String conversion functions */
  371. #define _tcstold    strtold
  372. #define _tcstod        strtod
  373. #define _tcstol        strtol
  374. #define _tcstoul    strtoul
  375. #define _itot        _itoa
  376. #define _ltot        _ltoa
  377. #define _ultot        _ultoa
  378. #define _ttoi        atoi
  379. #define _ttol        atol
  380.  
  381. /* String functions */
  382. #define _tcscat        strcat
  383. #define _tcscpy        strcpy
  384. #define _tcslen        strlen
  385. #define _tcsxfrm    strxfrm
  386. #define _tcscoll    strcoll
  387. #define _tcsdup        _strdup
  388. #define _tcsicoll    _stricoll
  389. #define _tcsnicoll    _strnicoll
  390.  
  391. /* Execute functions */
  392. #define _texecl        _execl
  393. #define _texecle    _execle
  394. #define _texeclp    _execlp
  395. #define _texeclpe    _execlpe
  396. #define _texecv        _execv
  397. #define _texecve    _execve
  398. #define _texecvp    _execvp
  399. #define _texecvpe    _execvpe
  400. #define _tspawnl    _spawnl
  401. #define _tspawnle    _spawnle
  402. #define _tspawnlp    _spawnlp
  403. #define _tspawnlpe    _spawnlpe
  404. #define _tspawnv    _spawnv
  405. #define _tspawnve    _spawnve
  406. #define _tspawnvp    _spawnvp
  407. #define _tspawnvpe    _spawnvpe
  408. #define _tsystem    system
  409.  
  410. /* Time functions */
  411. #define _tasctime    asctime
  412. #define _tctime        ctime
  413. #define _tstrdate    _strdate
  414. #define _tstrtime    _strtime
  415. #define _tutime        utime
  416. #define _tcsftime    strftime
  417.  
  418. /* Directory functions */
  419. #define _tchdir        _chdir
  420. #define _tgetcwd    _getcwd
  421. #define _tgetdcwd    _getdcwd
  422. #define _tmkdir        _mkdir
  423. #define _trmdir        _rmdir
  424.  
  425. /* Environment/Path functions */
  426. #define _tfullpath    _fullpath
  427. #define _tgetenv    getenv
  428. #define _tmakepath    _makepath
  429. #define _tputenv    _putenv
  430. #define _tsearchenv    _searchenv
  431. #define _tsplitpath    _splitpath
  432.  
  433. /* Stdio functions */
  434. #  ifdef _POSIX_
  435. #define _tfdopen    fdopen
  436. #  else
  437. #define _tfdopen    _fdopen
  438. #  endif
  439. #define _tfsopen    _fsopen
  440. #define _tfopen        fopen
  441. #define _tfreopen    freopen
  442. #define _tperror    perror
  443. #define _tpopen        _popen
  444. #define _ttempnam    _tempnam
  445. #define _ttmpnam    tmpnam
  446.  
  447. /* Io functions */
  448. #define _taccess    _access
  449. #define _tchmod        _chmod
  450. #define _tcreat        _creat
  451. #define _tfindfirst    _findfirst
  452. #define _tfindnext    _findnext
  453. #define _tmktemp    _mktemp
  454. #define _topen        _open
  455. #define _tremove    remove
  456. #define _trename    rename
  457. #define _tsopen        _sopen
  458. #define _tunlink    _unlink
  459. #define _tfinddata_t    _finddata_t
  460. #define _tFIND        FINDA
  461.  
  462. /* Ctype functions */
  463. #define _istascii    isascii
  464. #define _istcntrl    iscntrl
  465. #define _istxdigit    isxdigit
  466.  
  467. /* Stat functions */
  468. #define _tstat        _stat
  469.  
  470. /* Setlocale functions */
  471. #define _tsetlocale    setlocale
  472.  
  473. #  ifdef _MBCS
  474. /* Multi-byte character support */
  475. #include <mbstring.h>
  476.  
  477. typedef char            _TCHAR;
  478. typedef signed char     _TSCHAR;
  479. typedef unsigned char   _TUCHAR;
  480. typedef unsigned char   _TXCHAR;
  481. typedef unsigned int    _TINT;
  482.  
  483. #if !defined(_TCHAR_DEFINED)
  484. #   ifndef __STDC__
  485. typedef char            TCHAR;
  486. #   endif
  487. #define _TCHAR_DEFINED 1
  488. #endif
  489.  
  490. /* Since the types for the MBCS routines do not
  491.    match those of the single byte routines, there
  492.    has to be some type-safe mappings. The easiest
  493.    way to acomplish is through routines that cast
  494.    appropriately.  By default, these routines are inlined.
  495. */
  496. #   ifdef _MB_MAP_DIRECT
  497. /* use mb functions directly - types must match */
  498.  
  499. /* String functions */
  500. #define _tcschr        _mbschr
  501. #define _tcscspn    _mbscspn
  502. #define _tcsncat    _mbsnbcat
  503. #define _tcsncpy    _mbsnbcpy
  504. #define _tcspbrk    _mbspbrk
  505. #define _tcsrchr    _mbsrchr
  506. #define _tcsspn        _mbsspn
  507. #define _tcsstr        _mbsstr
  508. #define _tcstok        _mbstok
  509. #define _tcsnset    _mbsnbset
  510. #define _tcsrev        _mbsrev
  511. #define _tcsset        _mbsset
  512. #define _tcscmp        _mbscmp
  513. #define _tcsicmp    _mbsicmp
  514. #define _tcsnccmp    _mbsncmp
  515. #define _tcsncmp    _mbsnbcmp
  516. #define _tcsncicmp    _mbsnicmp
  517. #define _tcsnicmp    _mbsnbicmp
  518. #define _tcscoll    _mbscoll
  519. #define _tcsicoll    _mbsicoll
  520. #define _tcsnccoll    _mbsncoll
  521. #define _tcsncoll    _mbsnbcoll
  522. #define _tcsncicoll    _mbsnicoll
  523. #define _tcsnicoll    _mbsnbicoll
  524.  
  525. /* "logical-character" mappings */
  526. #define _tcsclen    _mbslen
  527. #define _tcsnccat    _mbsncat
  528. #define _tcsnccpy    _mbsncpy
  529. #define _tcsncset    _mbsnset
  530.  
  531. /* MBCS-specific mappings */
  532. #define    _tcsdec        _mbsdec
  533. #define    _tcsinc        _mbsinc
  534. #define    _tcsnbcnt    _mbsnbcnt
  535. #define    _tcsnccnt    _mbsnccnt
  536. #define    _tcsnextc    _mbsnextc
  537. #define    _tcsninc    _mbsninc
  538. #define    _tcsspnp    _mbsspnp
  539. #define _tcslwr        _mbslwr
  540. #define _tcsupr        _mbsupr
  541. #define _tclen        _mbclen
  542. #define _tccpy        _mbccpy
  543.  
  544. #   elif __STDC__ || defined(_NO_INLINING)
  545.  
  546. /* String functions */
  547. char * __cdecl _tcschr(const char *, unsigned int);
  548. int __cdecl _tcscmp(const char *, const char *);
  549. size_t __cdecl _tcscspn(const char *, const char *);
  550. int __cdecl _tcsncmp(const char *, const char *, size_t);
  551. char * __cdecl _tcsncpy(char *, const char *, size_t);
  552. char * __cdecl _tcspbrk(const char *, const char *);
  553. char * __cdecl _tcsrchr(const char *, int);
  554. size_t __cdecl _tcsspn(const char *, const char *);
  555. char * __cdecl _tcsstr(const char *, const char *);
  556. char * __cdecl _tcstok(char *, const char *);
  557. int __cdecl _tcsicmp(const char *, const char *);
  558. int __cdecl _tcsnicmp(const char *, const char *, size_t);
  559. char * __cdecl _tcsrev(char *);
  560.  
  561. /* "logical-character" mappings */
  562. size_t __cdecl _tcsclen(const char *);
  563. int __cdecl _tcsnccmp(const char *,const char *,size_t);
  564.  
  565. /* MBCS-specific mappings */
  566. char * __cdecl _tcsdec(const char *, const char *);
  567. char * __cdecl _tcsinc(const char *);
  568. char * __cdecl _tcsninc(const char *_s1,size_t _n);
  569. size_t __cdecl _tclen(const char *);
  570.  
  571. /* Helper */
  572. unsigned int __cdecl _tcsnextc(const char *);
  573.  
  574. #   else
  575.  
  576. /* String functions */
  577. __inline char * _tcschr(const char *_s1,unsigned int _c) {return (char *)_mbschr((const unsigned char *)_s1,_c);}
  578. __inline int  _tcscmp(const char * _s1,const char * _s2) {return _mbscmp((const unsigned char *)_s1,(const unsigned char *)_s2);}
  579. __inline size_t _tcscspn(const char * _s1,const char * _s2) {return _mbscspn((const unsigned char *)_s1,(const unsigned char *)_s2);}
  580. __inline int _tcsncmp(const char * _s1,const char * _s2,size_t _n) {return _mbsnbcmp((const unsigned char *)_s1,(const unsigned char *)_s2,_n);}
  581. __inline char * _tcsncpy(char * _s1,const char * _s2,size_t _n) {return (char *)_mbsnbcpy((unsigned char *)_s1,(const unsigned char *)_s2,_n);}
  582. __inline char * _tcspbrk(const char * _s1,const char * _s2) {return (char *)_mbspbrk((const unsigned char *)_s1,(const unsigned char *)_s2);}
  583. __inline char * _tcsrchr(const char * _s1,unsigned int _c) {return (char *)_mbsrchr((const unsigned char *)_s1,_c);}
  584. __inline size_t _tcsspn(const char * _s1,const char * _s2) {return _mbsspn((const unsigned char *)_s1,(const unsigned char *)_s2);}
  585. __inline char * _tcsstr(const char * _s1,const char * _s2) {return (char *)_mbsstr((const unsigned char *)_s1,(const unsigned char *)_s2);}
  586. __inline char * _tcstok(char * _s1,const char * _s2) {return (char *)_mbstok((unsigned char *)_s1,(const unsigned char *)_s2);}
  587. __inline int _tcsicmp(const char * _s1,const char * _s2) {return _mbsicmp((const unsigned char *)_s1,(const unsigned char *)_s2);}
  588. __inline int _tcsnicmp(const char * _s1,const char * _s2,size_t _n) {return _mbsnbicmp((const unsigned char *)_s1,(const unsigned char *)_s2,_n);}
  589. __inline char * _tcsrev(char * _s1) {return (char *)_mbsrev((unsigned char *)_s1);}
  590.  
  591. /* "logical-character" mappings */
  592. __inline size_t _tcsclen(const char * _s1) {return _mbslen((const unsigned char *)_s1);}
  593. __inline int _tcsnccmp(const char * _s1,const char * _s2,size_t _n) {return _mbsncmp((const unsigned char *)_s1,(const unsigned char *)_s2,_n);}
  594.  
  595. /* MBCS-specific mappings */
  596. __inline char * _tcsdec(const char * _s1,const char * _s2) {return (char *)_mbsdec((const unsigned char *)_s1,(const unsigned char *)_s2);}
  597. __inline char * _tcsinc(const char * _s1) {return (char *)_mbsinc((const unsigned char *)_s1);}
  598. __inline char * _tcsninc(const char *_s1,size_t _n) {return (char *)_mbsninc((const unsigned char *)_s1,_n);}
  599. __inline size_t _tclen(const char * _s1) {return _mbclen((const unsigned char *)_s1);}
  600.  
  601. /* Helper */
  602. __inline unsigned int _tcsnextc(const char * _s1) {unsigned int _n=0; if (_ismbblead((unsigned int)(unsigned char *)*_s1)) _n=((unsigned int)*_s1++)<<8; _n+=(unsigned int)*_s1; return(_n);}
  603.  
  604. #   endif
  605.  
  606. /* MBCS-specific mappings */
  607. #define    _tccmp(_c1,_c2)    _tcsnccmp(_c1,_c2,1)
  608.  
  609. /* Ctype functions */
  610. #define _istalnum    _ismbcalnum
  611. #define _istalpha    _ismbcalpha
  612. #define _istdigit    _ismbcdigit
  613. #define _istgraph    _ismbcgraph
  614. #define _istlegal    _ismbclegal
  615. #define _istlower    _ismbclower
  616. #define _istprint    _ismbcprint
  617. #define _istpunct    _ismbcpunct
  618. #define _istspace    _ismbcspace
  619. #define _istupper    _ismbcupper
  620. #define _totupper    _mbctoupper
  621. #define _totlower    _mbctolower
  622. #define _istlead    _ismbblead
  623. #define _istleadbyte    isleadbyte
  624.  
  625. #  else /* !_MBCS */
  626.  
  627. /* Single-Byte Character routines */
  628. typedef char            _TCHAR;
  629. typedef signed char     _TSCHAR;
  630. typedef unsigned char   _TUCHAR;
  631. typedef char            _TXCHAR;
  632. typedef int             _TINT;
  633.  
  634. #if !defined(_TCHAR_DEFINED)
  635. #   ifndef __STDC__
  636. typedef char            TCHAR;
  637. #   endif
  638. #define _TCHAR_DEFINED 1
  639. #endif
  640.  
  641. /* String functions */
  642. #define _tcschr        strchr
  643. #define _tcscmp        strcmp
  644. #define _tcscspn    strcspn
  645. #define _tcsncat    strncat
  646. #define _tcsncmp    strncmp
  647. #define _tcsncpy    strncpy
  648. #define _tcspbrk    strpbrk
  649. #define _tcsrchr    strrchr
  650. #define _tcsspn        strspn
  651. #define _tcsstr        strstr
  652. #define _tcstok        strtok
  653. #define _tcsicmp    _stricmp
  654. #define _tcsnicmp    _strnicmp
  655. #define _tcsnset    _strnset
  656. #define _tcsrev        _strrev
  657. #define _tcsset        _strset
  658.  
  659. /* "logical-character" mappings */
  660. #define _tcsclen    strlen
  661. #define _tcsnccat    strncat
  662. #define _tcsnccpy    strncpy
  663. #define _tcsnccmp    strncmp
  664. #define _tcsncicmp    _strnicmp
  665. #define _tcsncset    _strnset
  666.  
  667. /* MBCS-specific functions */
  668. #define    _tcsdec        _strdec
  669. #define    _tcsinc        _strinc
  670. #define    _tcsnbcnt    _strncnt
  671. #define    _tcsnccnt    _strncnt
  672. #define    _tcsnextc    _strnextc
  673.  
  674. #define    _tcsninc    _strninc
  675. #define    _tcsspnp    _strspnp
  676. #define _tcslwr        _strlwr
  677. #define _tcsupr        _strupr
  678. #define _tcsxfrm    strxfrm
  679. #define _istlead(_c)    (0)
  680. #define _istleadbyte(_c)    (0)
  681.  
  682. #   if __STDC__ || defined(_NO_INLINING)
  683. #define _tclen(_pc)    (1)
  684. #define _tccpy(_pc1,_cpc2) (*(_pc1) = *(_cpc2))
  685. #define _tccmp(_cpc1,_cpc2) (((unsigned char)*(_cpc1))-((unsigned char)*(_cpc2)))
  686. #   else /* __STDC__ */
  687. __inline size_t __cdecl _tclen(const char *_cpc) { return (_cpc,1); }
  688. __inline void __cdecl _tccpy(char *_pc1, const char *_cpc2) { *_pc1 = *_cpc2; }
  689. __inline int __cdecl _tccmp(const char *_cpc1, const char *_cpc2) { return (int) (((unsigned char)*_cpc1)-((unsigned char)*_cpc2)); }
  690. #   endif /* __STDC__ */
  691.  
  692. /* Ctype-functions */
  693. #define _istalnum    isalnum
  694. #define _istalpha    isalpha
  695. #define _istdigit    isdigit
  696. #define _istgraph    isgraph
  697. #define _istlower    islower
  698. #define _istprint    isprint
  699. #define _istpunct    ispunct
  700. #define _istspace    isspace
  701. #define _istupper    isupper
  702. #define _totupper    toupper
  703. #define _totlower    tolower
  704. #define _istlegal(_c)   (1)
  705.  
  706. /* define NULL pointer value */
  707. #   ifndef NULL
  708. #    ifdef __cplusplus
  709. #define NULL    0
  710. #    else
  711. #define NULL    ((void *)0)
  712. #    endif
  713. #   endif
  714.  
  715. #   if __STDC__ || defined(_NO_INLINING)
  716. #define _strdec(_cpc1, _cpc2) ((_cpc2)-1)
  717. #define _strinc(_pc)    ((_pc)+1)
  718. #define _strnextc(_cpc)    ((unsigned int) *(_cpc))
  719. #define _strninc(_pc, _sz) (((_pc)+(_sz)))
  720. #define _strncnt(_cpc, _sz) ((strlen(_cpc)>_sz) ? _sz : strlen(_cpc))
  721. #define _strspnp(_cpc1, _cpc2) ((*((_cpc1)+strspn(_cpc1,_cpc2))) ? ((_cpc1)+strspn(_cpc1,_cpc2)) : NULL)
  722. #   else /* __STDC__ */
  723. __inline char * __cdecl _strdec(const char * _cpc1, const char * _cpc2) { return (char *)(_cpc1,(_cpc2-1)); }
  724. __inline char * __cdecl _strinc(const char * _pc) { return (char *)(_pc+1); }
  725. __inline unsigned int __cdecl _strnextc(const char * _cpc) { return (unsigned int)*_cpc; }
  726. __inline char * __cdecl _strninc(const char * _pc, size_t _sz) { return (char *)(_pc+_sz); }
  727. __inline size_t __cdecl _strncnt( const char * _cpc, size_t _sz) { size_t len; len = strlen(_cpc); return (len>_sz) ? _sz : len; }
  728. __inline char * __cdecl _strspnp( const char * _cpc1, const char * _cpc2) { return (*(_cpc1 += strspn(_cpc1,_cpc2))!='\0') ? (char*)_cpc1 : NULL; }
  729. #   endif /* __STDC__ */
  730.  
  731. #  endif /* _MBCS */
  732.  
  733. # endif /* _UNICODE */
  734.  
  735. #define _T(x)        __T(x)
  736. #define _TEXT(x)    __T(x)
  737.  
  738. # if __cplusplus
  739. }
  740. # endif
  741.  
  742. #endif
  743.